package com.qf.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.qf.mapper.UserMapper;
import com.qf.model.User;
import com.qf.service.UserService;
import com.qf.util.ResultData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
@Service
public class UserServiceImpl implements UserService {
    @Autowired
    private UserMapper userMapper;

    @Override
    public ResultData findAll() {
        //使用分页
        PageHelper.startPage(2,5);
        //调用数据层
        List<User> users = userMapper.findAll();
        //获得分页数据
        PageInfo<User> info = new PageInfo<>(users);
        long count = info.getTotal();
        return ResultData.ok(users,count);
    }
}
